//
//  ViewController.m
//  KingReaderSDKDemo
//
//  Created by wangbc on 16/3/24.
//  Copyright © 2016年 Shanghai Lianyou Network Technology Co., Ltd. All rights reserved.
//

#import "ViewController.h"
#import "KingReaderSDK.h"
#define Random arc4random() % 256 / 255.0f
#define ColorRandom [UIColor colorWithRed:Random green:Random blue:Random alpha:1.0f]

@interface ViewController ()

@property (weak, nonatomic) IBOutlet UIButton *button;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//仅用于测试使用,GDT默认关闭
- (IBAction)turnOnGDT:(UIButton *)sender {
    sender.selected = ! sender.selected;
    [KingReaderSDK setGDTTurnOn:self.button.selected];
}

- (IBAction)tabBarColor:(UIButton *)sender {
    [KingReaderSDK setNavigationForgroundColor:ColorRandom];
    //[KingReaderSDK setNavigationBackgroundColor:[UIColor darkGrayColor]];
    //[KingReaderSDK setTabbarBackgroundColor:[UIColor lightGrayColor]];
    [KingReaderSDK setTabbarSelectedColor:ColorRandom];
    [KingReaderSDK setTabbarNormalColor:ColorRandom];
}

- (IBAction)buttonTapped:(id)sender {
    if (![KingReaderSDK isLogined]) {
        //用第三方账号登陆
        [KingReaderSDK loginWithUniqueId:@"ef2daaafae2f333fq23fqdafsdf3f2" channelId:99 completeBlock:^(NSString *error, BOOL succeed) {
            if (succeed) {
                UIViewController *vc = [KingReaderSDK rootViewController];
                [self.navigationController pushViewController:vc animated:YES];
            }
        }];
    } else {
        UIViewController *vc = [KingReaderSDK rootViewController];
        [self.navigationController pushViewController:vc animated:YES];
    }
    
}

@end
